package com.redstar.HappyRefresh.json;

import lombok.Data;
import org.springframework.util.ObjectUtils;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;


@Data
//@ToString
public class BodyJson implements Serializable { // 用于封装视频内容审核的结果

    String id;
    String status; // 状态
    ResultJson result; // 审核结果

    public boolean checkViolation(List<CutsJson> types, Double min) { // 判断审核结果在哪个审核标准的范围内
        for (CutsJson cutsJson : types) {
            if (!ObjectUtils.isEmpty(cutsJson.details)) {
                for (DetailsJson detail : cutsJson.details) { // 截帧审核详细信息集合
                    Double score = detail.getScore();
                    if (score >= min) { // 置信度大于人工审核标准的最小值，审核结果为人工审核或审核失败
                        return true;
                    }
                }
            }
        }
        // 审核通过
        return false;
    }

    public List<CutsJson> getTerror() { // 返回暴恐的审核结果
        TypeJson terror = result.getResult().getScenes().getTerror();
        if (!ObjectUtils.isEmpty(terror.getCuts())) {
            return terror.getCuts();
        }
        CutsJson cutsJson = new CutsJson();
        cutsJson.setDetails(terror.getDetails());
        cutsJson.setSuggestion(terror.getSuggestion());
        return Collections.singletonList(cutsJson);
    }

    public List<CutsJson> getPolitician() { // 返回政治的审核结果
        TypeJson politician = result.getResult().getScenes().getPolitician();
        if (!ObjectUtils.isEmpty(politician.getCuts())) {
            return politician.getCuts();
        }
        CutsJson cutsJson = new CutsJson();
        cutsJson.setDetails(politician.getDetails());
        cutsJson.setSuggestion(politician.getSuggestion());
        return Collections.singletonList(cutsJson);
    }

    public List<CutsJson> getPulp() { // 返回色情的审核结果
        TypeJson pulp = result.getResult().getScenes().getPulp();
        if (!ObjectUtils.isEmpty(pulp.getCuts())) {
            return pulp.cuts;
        }
        CutsJson cutsJson = new CutsJson();
        cutsJson.setDetails(pulp.getDetails());
        cutsJson.setSuggestion(pulp.getSuggestion());
        return Collections.singletonList(cutsJson);
    }
}
